From ce5a0c5cd2ed4ef80b3bbbf3e91dcfe45ee7955c Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 3 Jun 2015 08:03:20 -0700 Subject: [PATCH] registration: Don't override boolean false settings Our optimization of !$GLOBALS[$key] was affecting settings where a true setting was being disabled in LocalSettings.php. Now explicitly check it is an array before overriding it. Bug: T100767 Change-Id: Id5397e526d66559bfabe6065223b1181a8a9d31e --- includes/registration/ExtensionRegistry.php | 2 +- .../registration/ExtensionRegistryTest.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index e46c753be9..d767870a70 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -163,7 +163,7 @@ class ExtensionRegistry { protected function exportExtractedData( array $info ) { foreach ( $info['globals'] as $key => $val ) { - if ( !isset( $GLOBALS[$key] ) || !$GLOBALS[$key] ) { + if ( !isset( $GLOBALS[$key] ) || ( is_array( $GLOBALS[$key] ) && !$GLOBALS[$key] ) ) { $GLOBALS[$key] = $val; } elseif ( $key === 'wgHooks' || $key === 'wgExtensionCredits' ) { // Special case $wgHooks and $wgExtensionCredits, which require a recursive merge. diff --git a/tests/phpunit/includes/registration/ExtensionRegistryTest.php b/tests/phpunit/includes/registration/ExtensionRegistryTest.php index 8674343447..515ce11fcb 100644 --- a/tests/phpunit/includes/registration/ExtensionRegistryTest.php +++ b/tests/phpunit/includes/registration/ExtensionRegistryTest.php @@ -191,7 +191,19 @@ class ExtensionRegistryTest extends MediaWikiTestCase { ) ), ), - ) + ), + array( + 'False local setting should not be overridden (T100767)', + array( + 'mwtestT100767' => false, + ), + array( + 'mwtestT100767' => true, + ), + array( + 'mwtestT100767' => false, + ), + ), ); } } -- 2.20.1